﻿Imports DTO

Public Class ReceiptDAO
    Public Sub InsertReceipt(ByVal bookingId As Integer, ByVal timeIn As String)
        Try
            Dim strSQL As String = String.Format("INSERT INTO Receipt (BookingID, PaymentMethod,TimeIn,TimeOut, TotalPrice) VALUES({0}, null, '{1}', '', 0)", bookingId, timeIn)
            Connection.ExcuteQuery(strSQL)
            Connection.Dispose()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub UpdateReceipt(ByVal bookingId As Integer, ByVal timeOut As String, ByVal payment As String, ByVal total As Double)
        Try
            Dim sSQL As String = "UPDATE Receipt SET "
            sSQL = String.Format("{0} TimeOut='{1}', PaymentMethod='{2}', TotalPrice={3}", sSQL, timeOut, payment, total)
            'sSQL = String.Format("{0} ", sSQL)
            sSQL = String.Format("{0} Where BookingId={1} ", sSQL, bookingId)
            Connection.ExcuteQuery(sSQL)
            Connection.Dispose()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    'Public Function GetListReceipt() As List(Of ReceiptDTO)
    '    Dim listResult As New List(Of ServiceDTO)
    '    Try
    '        Dim sql As String = "select ServiceID, isNull(Price,0) Price, isNull(Name,'') Name from Service  order by Price "
    '        Dim reader As SqlDataReader
    '        reader = Connection.ExcuteReader(sql)
    '        While (reader.Read)
    '            Dim service As New ServiceDTO
    '            service.ServiceID = reader("ServiceID")
    '            service.Price = reader("Price")
    '            service.Name = reader("Name")
    '            listResult.Add(service)
    '        End While
    '        reader.Close()
    '        Connection.Dispose()
    '    Catch ex As Exception
    '        Throw ex
    '    End Try
    '    Return listResult
    'End Function
End Class
